#!/bin/ksh

##################################################
# name: S20jenkins
# purpose: script that will start or stop jenkins
##################################################

case "$1" in
start )
        su - {{server_user}} -c '\
              ulimit -c 0; \
	      ulimit -d unlimited; \
	      ulimit -m unlimited; \
	      export TERM=ansi; \
              export jenkins_log_file="/home/{{server_user}}/jenkins_console.log"; \
              export HOME=/home/{{server_user}}; \
              export NODE_TEST_DIR=$HOME/tmp; \
              export NODE_COMMON_PIPE="$HOME/test.pipe"; \
              export OSTYPE=AIX72; \
              export JOBS={{ jobs_env }}; \
        /usr/bin/java -Xmx128m -Dorg.jenkinsci.plugins.gitclient.Git.timeOut=30 -jar "$HOME/slave.jar" \
          -secret {{secret}} \
          -jnlpUrl {{jenkins_url}}/computer/{{inventory_hostname}}/slave-agent.jnlp >$jenkins_log_file 2>&1 &'
        ;;
stop )
        ;;
* )
        echo "Usage: $0 (start | stop)"
        exit 1
esac
